<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>我的</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link href="../../css/iconfont.css" rel="stylesheet" />
		<link href="../../iconfont/iconfont.css" rel="stylesheet" />
		<style type="text/css">
		.icon-gear.shezhi:before {content: "\e665";color: darkslategrey;}
		.icon-dingdan1:before {font-size: 24px;}
		.icon-daifukuan:before {font-size: 24px;}
		.icon-liulanzuji:before {font-size: 24px;}
		.icon-xiedianping:before {font-size: 24px;}
		.icon-jifen1:before {font-size: 32px;color: #F0AD4E;}
		.icon-weibiaoti2fuzhi02:before {font-size: 32px;color: darkseagreen;}
		ul.subCash {margin-top: 10px !important;padding-bottom: 0px !important;padding-right: 0px !important;}
		.sublist {padding: 10px 14px !important;}
		.sublist1 {border-right: dashed 1px #c0c0c0;}
		span.detail {color: #CCCCCC;display: inline-block;}
		.icon-youji_1:before {font-size: 26px;color: mediumseagreen;}
		.icon-jieban:before {font-size: 24px;color: yellowgreen;}
		.icon-gerenzhongxin:before {font-size: 26px;color: orange}
		.icon-shouye:before {font-size: 26px;color: deepskyblue;}
		span.iconPosition {margin-right: 10px;}
		.mylist {padding-top: 12px;padding-bottom: 12px;}
		.icon-yonghudianping:before {font-size: 26px;color: palevioletred}
		.icon-lvyou:before {font-size: 26px;color: lightseagreen}
		/*修改，，待确定*/
		li#info{padding: 20px 15px;text-align: center;}
		img#touxiang{border-radius: 50%;line-height: 80px !important;max-width: 80px !important;height: 80px !important;box-shadow: 0px 0px 15px cadetblue;}
		.mui-bar{background-color: #e2f3e9;-webkit-box-shadow:none !important;box-shadow:none !important;}
		.mui-bar-nav{-webkit-box-shadow:none !important;box-shadow:none !important;}
		ul#yonghu{background-color: #e2f3e9;margin-top: 0px;}
		</style>
		<script src="../../js/mui.min.js" type="text/javascript"></script>
		<script src="../../js/jquery.min.js" type="text/javascript"></script>
		<script src="../../js/app.js" type="text/javascript"></script>
		<script src="../../js/us/login.js" type="text/javascript"></script>
	</head>

	<body>
		<!--header s-->
		<header class="mui-bar mui-bar-nav">
			<a class=" mui-icon iconfont icon-gear mui-pull-right shezhi" id="set"></a>
			<!--<h1 class="mui-title">我的</h1>-->
		</header>
		<!--header e-->
		<!--主内容区     s-->
		<div class="mui-content" id="person">
			<ul class="mui-table-view" id="yonghu">
				<li class="mui-table-view-cell mui-media" id="info">
					<a href="javascript:void(0);" id="login">
						<img class="mui-media-object" src="../../img/touxiang.jpg" id="touxiang">
						<div class="mui-media-body" id="nickname">
							未登录
						</div>
					</a>
				</li>
			</ul>
			<ul class="mui-table-view mui-grid-view mui-grid-12" style="margin-top: 10px;">
				<li class="mui-table-view-cell mui-media mui-col-xs-3">
					<a href="#" id="orders">
						<span class="mui-icon iconfont icon-dingdan1"></span>
						<div class="mui-media-body">订单</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-3">
					<a href="#">
						<span class="mui-icon iconfont icon-daifukuan"></span>
						<div class="mui-media-body">待付款</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-3">
					<a href="#">
						<span class="mui-icon iconfont icon-liulanzuji"></span>
						<div class="mui-media-body">待出行</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-3">
					<a href="#">
						<span class="mui-icon iconfont icon-xiedianping"></span>
						<div class="mui-media-body">待点评</div>
					</a>
				</li>
			</ul>
			<ul class="mui-table-view mui-grid-view mui-grid-12 subCash">
				<li class="mui-table-view-cell mui-media mui-col-xs-6 sublist1 sublist">
					<a href="#">
						<span class="mui-icon iconfont icon-jifen1"></span>
						<div class="mui-media-body">积分<span class="detail">(0分)</span></div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-6 sublist2 sublist">
					<a href="#">
						<span class="mui-icon iconfont icon-weibiaoti2fuzhi02"></span>
						<div class="mui-media-body">优惠券<span class="detail">(0张)</span></div>
					</a>
				</li>
			</ul>
			<ul class="mui-table-view mui-table-view-chevron" style="margin-top: 15px;">
				<li class="mui-table-view-cell mylist">
					<a href="#score" class="mui-navigate-right"><span class="mui-icon iconfont icon-youji_1 iconPosition"></span>我的游记</a>
				</li>
				<li class="mui-table-view-cell mylist">
					<a href="#non-payment" class="mui-navigate-right"><span class="mui-icon iconfont icon-jieban iconPosition"></span>我的结伴</a>
				</li>
				<li class="mui-table-view-cell mylist">
					<a href="#consult" class="mui-navigate-right"><span class="mui-icon iconfont icon-shouye iconPosition"></span>我的咨询</a>
				</li>
				<li class="mui-table-view-cell mylist">
					<a href="#evaluate" class="mui-navigate-right"><span class="mui-icon iconfont icon-yonghudianping iconPosition"></span>我的点评</a>
				</li>
				<li class="mui-table-view-cell mylist">
					<a href="#evaluate" class="mui-navigate-right"><span class="mui-icon iconfont icon-lvyou iconPosition"></span>常用旅客</a>
				</li>
				<li class="mui-table-view-cell mylist">
					<a href="#evaluate" class="mui-navigate-right"><span class="mui-icon iconfont icon-gerenzhongxin iconPosition"></span>个人中心</a>
				</li>
			</ul>
		</div>
		<!--主内容区     e-->
	</body>
	<script type="text/javascript">
	//初始页面的区域滚动
	mui('.mui-scroll-wrapper').scroll();
	</script>
	<script type="text/javascript">
		(function($, doc) {
			var settings = app.getSettings();
			var account = doc.getElementById('nickname');
			var touxiang = doc.getElementById('touxiang');
			var myemail = doc.getElementById('myemail');
			var login=null;
			var logOut=null;
			//登录/注册信息的获取
			window.addEventListener('showMsg', function(event) {
				account.innerText=event.detail.nickname;
				touxiang.src=event.detail.touxiang;
			},false);
			window.addEventListener('show', function(event) {
				var state = app.getState();
				account.innerText = state.account;
				touxiang.src = state.imgurl;
				login=true;
			}, false);
			window.addEventListener('logout', function() {
				account.innerText = "未登录";
				touxiang.src = "../../img/touxiang.jpg";
				logOut=true;
			}, false);
			
			document.getElementById("set").addEventListener("tap",function(){
				mui.openWindow({
					url:'/html/person/setting/setting.html'
				})
			})
			mui.plusReady(function(){
				mui.preload({
					url:"../../main.html"
				});
				//打开我的订单页面
				document.getElementById("orders").addEventListener("tap",function(){
				//已登录时，跳转到订单列表页,未登录时，出现登录的提示信息
			    if(isLogin(plus)){
			    	mui.openWindow({
					url:'orders.html'
					});
			    }else{
			    	mui.toast("请登录");
			    	
			    	}
				});	
			
			//打开登录页面
				document.getElementById("login").addEventListener("tap",function(){
					//已登录时，暂时出现提示信息;未登录时跳转到登录页面
					if(isLogin(plus)){
						if(mui.os.plus){
						var a = [{
							title: "拍照"
						}, {
							title: "从手机相册选择"
						}];
						plus.nativeUI.actionSheet({
							title: "修改头像",
							cancel: "取消",
							buttons: a
							}, function(b) {
							switch (b.index) {
							case 0:
								break;
							case 1:
								getImage();
								break;
							case 2:
								galleryImg();
							break;
							default:
								break
						}
					})	
					}
					//getImage()	
					function getImage() {
							var c = plus.camera.getCamera();
					c.captureImage(function(e) {
							plus.io.resolveLocalFileSystemURL(e, function(entry) {
								var s = entry.toLocalURL() + "?version=" + new Date().getTime();
								console.log(s);
								document.getElementById("touxiang").src = s;
								//document.getElementById("touxiang1").src = s;
								//变更大图预览的src
								//目前仅有一张图片，暂时如此处理，后续需要通过标准组件实现
								document.querySelector("#__mui-imageview__group .mui-slider-item img").src = s + "?version=" + new Date().getTime();;;
								}, function(e) {
									console.log("读取拍照文件错误：" + e.message);
							});
						}, function(s) {
							console.log("error" + s);
					}, {
						filename: "_doc/head.jpg"
						});
					}	
						
					function galleryImg() {
						plus.gallery.pick(function(a) {
							plus.io.resolveLocalFileSystemURL(a, function(entry) {
								plus.io.resolveLocalFileSystemURL("_doc/", function(root) {
									root.getFile("head.jpg", {}, function(file) {
									//文件已存在
									file.remove(function() {
										console.log("file remove success");
											entry.copyTo(root, 'head.jpg', function(e) {
											var e = e.fullPath + "?version=" + new Date().getTime();
											document.getElementById("touxiang").src = e;
										document.getElementById("touxiang1").src = e;
										//变更大图预览的src
										//目前仅有一张图片，暂时如此处理，后续需要通过标准组件实现
										document.querySelector("#__mui-imageview__group .mui-slider-item img").src = e + "?version=" + new Date().getTime();;
									},
									function(e) {
										console.log('copy image fail:' + e.message);
									});
							}, function() {
								console.log("delete image fail:" + e.message);
							});
						}, function() {
							//文件不存在
							entry.copyTo(root, 'head.jpg', function(e) {
									var path = e.fullPath + "?version=" + new Date().getTime();
									document.getElementById("touxiang").src = path;
									document.getElementById("touxiang1").src = path;
									//变更大图预览的src
									//目前仅有一张图片，暂时如此处理，后续需要通过标准组件实现
									document.querySelector("#__mui-imageview__group .mui-slider-item img").src = path;
								},
								function(e) {
									console.log('copy image fail:' + e.message);
								});
						});
					}, function(e) {
						console.log("get _www folder fail");
					})
				}, function(e) {
					console.log("读取拍照文件错误：" + e.message);
				});
			}, function(a) {}, {
				filter: "image"
			})
		};	
						
						
						
						
						
						
						
						
						
						
						
						mui.toast("已登录成功");
					}else{
						mui.openWindow({
							url:"../../login/login.html"
						});
					}
				})
			
			
			});
				
			}(mui, document));
		</script>
</html>